#!/usr/bin/python

import sys
import unittest
import zverinec

class FakeOptions(object):
  """Fake option object. """

class TestZverinec(unittest.TestCase):
  def testZvieraDescribe(self):
    zviera_obj = zverinec.Zviera()
    self.assertEquals('My name is None, I have heads: 1, tails: None, legs: None, '
      'fur color: None.', zviera_obj.Describe())
    zviera_obj.name = 'Jojo'
    zviera_obj.num_heads = 3
    zviera_obj.num_legs = 11
    zviera_obj.num_tails = 5
    zviera_obj.fur_color = 'green'
    self.assertEquals('My name is Jojo, I have heads: 3, tails: 5, legs: 11, '
      'fur color: green.', zviera_obj.Describe())
  
  def testZvieraMakeSound(self):
    zviera_obj = zverinec.Zviera()
    self.assertEquals('None', zviera_obj.MakeSound())
    zviera_obj.sound = 'haf'
    self.assertEquals('haf', zviera_obj.MakeSound())

  def testMackaInit(self):
    macka_obj = zverinec.Macka('Fluffy', 'white', 'Mnaw')
    self.assertEquals('Fluffy', macka_obj.name) 
    self.assertEquals('white', macka_obj.fur_color)
    self.assertEquals('Mnaw', macka_obj.sound)
    self.assertEquals(1, macka_obj.num_tails)
    self.assertEquals(4, macka_obj.num_legs)

  def testMackaSpi(self):
    macka_obj = zverinec.Macka('Blackie', 'black', 'Mnaw')
    self.assertEquals('A spim.', macka_obj.Spi())

  def testPesInit(self):
    pes_obj = zverinec.Pes('Dunco', 'brown', 'Haf')
    self.assertEquals('Dunco', pes_obj.name)
    self.assertEquals('brown', pes_obj.fur_color)
    self.assertEquals('Haf', pes_obj.sound)
    self.assertEquals(1, pes_obj.num_tails)
    self.assertEquals(4, pes_obj.num_legs)

  def testPesDones(self):
    pes_obj = zverinec.Pes('Dunco', 'brown', 'Haf')
    self.assertEquals('A nech sa paci.', pes_obj.Dones())

  def testHadInit(self):
    had_obj = zverinec.Had('Sykacka', None, 'Ssss')
    self.assertEqual('Sykacka', had_obj.name)
    self.assertEqual(None, had_obj.fur_color)
    self.assertEqual('Ssss', had_obj.sound)
    self.assertEqual(1, had_obj.num_tails)
    self.assertEqual(0, had_obj.num_legs)
  
  def testHadPlazSa(self):
    had_obj = zverinec.Had('Sykacka', None, 'Ssss')
    self.assertEqual('A plazim sa.', had_obj.PlazSa())

  def testKohutInit(self):
    kohut_obj = zverinec.Kohut('Kikirikac', None, 'Kikiriki')
    self.assertEqual('Kikirikac', kohut_obj.name)
    self.assertEqual(None, kohut_obj.fur_color)
    self.assertEqual('Kikiriki', kohut_obj.sound)
    self.assertEqual(2, kohut_obj.num_legs)
    self.assertEqual(1, kohut_obj.num_tails)


  def testUvodneKeci(self):
    output, instancia = zverinec.UvodneKeci(zverinec.Macka, 'Blackie', 
      'black', 'Miau')
    self.assertEquals('Creating instance Blackie.\n'
      'Calling Blackie.Describe(): My name is Blackie, I have heads: '
      '1, tails: 1, legs: 4, fur color: black.\n'
      'Calling Blackie.MakeSound(): Miau', output)
    self.assertEquals(zverinec.Macka, instancia.__class__)


if __name__ == '__main__':
  unittest.main()
